/**
 * Collaborative Story Development Web Application (CSDApp) Copyright Anton
 * Strack 2014
 *
 * This file is part of Collaborative Story Development Application (CSDApp).
 *
 * CSDApp is free software: you can redistribute it and/or modify it under the
 * terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or any later version.
 *
 * CSDApp is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * CSDApp. If not, see <http://www.gnu.org/licenses/>.
 *
 */
package csdwa;

import java.sql.Connection;

/**
 * This class makes the controllers for the resources.
 *
 * @author Anton Strack
 */
public class ControllerFactory {

    /**
     * Selects a controller based on the model resource id.
     *
     * @param resourceTypeId
     * @return
     */
    public static CsdwaController getController(int resourceTypeId, Connection conn) {
        CsdwaController controller;
        switch (resourceTypeId) {
            case 2:// post
            {
                controller = makePostController(conn);
                break;
            }
            case 3: // plot
            {
                controller = makePlotController(conn);
                break;
            }
            case 4: // character
            {
                controller = makeCharacterController(conn);
                break;
            }
            case 5: // dialog
            {
                controller = makeDialogController(conn);
                break;
            }
            case 6: // location
            {
                controller = makeLocationController(conn);
                break;
            }
            case 7: // comment
            {
                controller = makeCommentController(conn);
                break;
            }
            case 8: // category
            {
                controller = makeCategoryController(conn);
                break;
            }
            case 9: // relationship
            {
                controller = makeRelationshipController(conn);
                break;
            }

            case 16: // task
            {

                controller = makeTaskController(conn);
                break;
            }

            case 17: // notification
            {

                controller = makeNotificationTemplateController(conn);
                break;
            }

            case 20: // userHistory
            {
                controller = makeUserHistoryController(conn);
                break;
            }

            case 22: // administration controller // temp
            {
                controller = makeAdministrationController(conn);
                break;
            }
            case 24: // notification
            {

                controller = makeNotificationController(conn);
                break;
            }
            default: {
                controller = makeSiteController(conn);
                break;
            }
        }
        return controller;
    }

    /**
     * Make a post controller
     *
     * @param ds Data source that the controller can use
     * @return the controller
     */
    public static PostController makePostController(Connection conn) {
        return new PostController(conn);
    }

    /**
     * Make a plot controller
     *
     * @param ds Data source that the controller can use
     * @return the controller
     */
    public static PlotController makePlotController(Connection conn) {
        return new PlotController(conn);
    }

    /**
     * Make a character controller
     *
     * @param ds Data source that the controller can use
     * @return the controller
     */
    public static CharacterController makeCharacterController(Connection conn) {
        return new CharacterController(conn);
    }

    /**
     * Make a dialog controller
     *
     * @param ds Data source that the controller can use
     * @return the controller
     */
    public static DialogController makeDialogController(Connection conn) {
        return new DialogController(conn);
    }

    /**
     * Make a location controller
     *
     * @param ds Data source that the controller can use
     * @return the controller
     */
    public static LocationController makeLocationController(Connection conn) {
        return new LocationController(conn);
    }

    /**
     * Make a relationship controller
     *
     * @param ds Data source that the controller can use
     * @return the controller
     */
    public static RelationshipController makeRelationshipController(Connection conn) {
        return new RelationshipController(conn);
    }

    /**
     * Make a comment controller
     *
     * @param ds Data source that the controller can use
     * @return the controller
     */
    public static CommentController makeCommentController(Connection conn) {
        return new CommentController(conn);
    }

    /**
     * Make a post history controller
     *
     * @param ds Data source that the controller can use
     * @return the controller
     */
    public static UserHistoryController makeUserHistoryController(Connection conn) {
        return new UserHistoryController(conn);
    }
    /* // not sure about the setup of these yet**/

    public static NotificationTemplateController makeNotificationTemplateController(Connection conn) {
        return new NotificationTemplateController(conn);
    }

    // not sure about the setup of these yet
    public static TaskController makeTaskController(Connection conn) {
        return new TaskController(conn);
    }

    /**
     * Make a category controller
     *
     * @param ds Data source that the controller can use
     * @return the controller
     */
    public static CategoryController makeCategoryController(Connection conn) {
        return new CategoryController(conn);
    }

    /**
     * Make a site controller - which is basically the home page controller
     *
     * @param ds Data source that the controller can use
     * @return the controller
     */
    public static SiteController makeSiteController(Connection conn) {
        return new SiteController(conn);
    }

    /**
     * Make a administration controller
     *
     * @param ds Data source that the controller can use
     * @return the controller
     */
    public static AdministrationController makeAdministrationController(Connection conn) {
        return new AdministrationController(conn);
    }

    /**
     * Make a notification controller
     *
     * @param ds Data source that the controller can use
     * @return the controller
     */
    public static NotificationController makeNotificationController(Connection conn) {
        return new NotificationController(conn);
    }
}
